class User(object):
    def __init__(self, name, age):
        self._name = name  # 受保护变量
        self.__age = age  # 私有变量

    @property  # 获取变量
    def name(self):
        return self._name

    @name.setter
    def name(self, name):
        if isinstance(name, str):
            self._name = name
        else:
            raise Exception("名字格式错误！")

    @property  # 获取变量
    def age(self):
        return self.__age

    @age.setter
    def age(self, age):
        if 0 < age < 200:
            self.__age = age
        else:
            print("年龄设置错误！")

    def show(self):
        print(f"你好，我叫{self.name},我今年{self.age}岁。")


mia = User('mia', 19)
mia.name = 'jay'
mia.age = 100
mia.show()
